How the Hub Listens

Hub in Learning Mode
By clicking on "teach" button in a GUI on the touchscreen, a global variable OPTION is set to a value that corresponds to each type of alarm.User presses "record", if OPTION equals a non-zero integer, the learning program is run. Depending on the value of OPTION, a .wav file corresponding to the alarm type is open and has the sound that is recorded written to the file. A FFT is run on the .wav file, and the FFT is written to a .txt file. The user repeats this for each of the alarm types.

Hub in Active Mode
In active mode, the hub is always listening. If there is a sound greater than a volume threshold, then the hub begins to record for five seconds. It saves this recording to a .wav file, and then runs the compare program. The hub performs an FFT on the newly recorded .wav file and writes this to a .txt file. It then checks to see if the .txt file of the new sample matches any of the pre-recorded .txt files. When it finds a match, it sends an integer value corresponding to the alarm type via Bluetooth to the wristband. It then returns to active mode.

Bluetooth Messages

Upon receiving an integer value from the hub, the wristband passes this integer into a switch statement. This will wake the device out of sleep mode. Depending upon the alarm type, a different message is displayed on the LCD, and the LED is lit with a different color. The vibrator is activated with an I/O pin from the nRF52832 chip and pulses until the user presses the clear button. After the clear button is pressed, the LCD screen is erased and the vibrator is turned off. The wristband is then placed back into sleep mode.